package com.bawei.mall.product.controller;

import com.bawei.common.core.domain.R;
import com.bawei.mall.product.domain.MallProductFoot;
import com.bawei.mall.product.service.IMallProductFootService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：作者姓名
 * @Package：com.bawei.mall.product.controller
 * @Project：mall_cloud
 * @name：MallProductFootController
 * @Date：2024/7/3 14:43
 */
@RestController
@RequestMapping("/readHistory")
public class MallProductFootController {

    @Autowired
    private IMallProductFootService mallProductFootService;



    @GetMapping("/list")
    public R<List<MallProductFoot>> getMallProductFoot(MallProductFoot mallProductFoot){
        PageHelper.startPage(mallProductFoot.getPageNum(),mallProductFoot.getPageSize());
        List<MallProductFoot> mallProductFoots = mallProductFootService.selectMallProductFoot();
        PageInfo<MallProductFoot> mallProductFootPageInfo = new PageInfo<>(mallProductFoots);
        return R.ok(mallProductFootPageInfo.getList());
    }

    @PostMapping("/clear")
    public R clearMallProductFoot(){
        mallProductFootService.deleteAllMallProductFoot();
        return R.ok();
    }

    @PostMapping("/create")
    public R createMallProductFoot(@RequestBody MallProductFoot mallProductFoot){
        mallProductFootService.insertMallProductFoot(mallProductFoot);
        return R.ok();
    }





}
